/*
* $Id: JournalVisualComponent.cpp 143 2010-09-09 19:55:18Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "JournalVisualComponent.h"

#define JOURNAL_ID		0x1003

CJournalVisualComponent::CJournalVisualComponent(IJournalComponent* pComponent)
: m_JournalButton(IDB_JOURNAL, ILanguageManager::GetLanguageManager()->GetString(JOURNAL_CAPTION_ID)),
m_JournalWin(pComponent){}
CJournalVisualComponent::~CJournalVisualComponent(){}

IWnd* CJournalVisualComponent::GetButtonInMainWindow(){
	if(!IsWindow(m_JournalButton.m_hWnd)){
		CRect rect;
		CWnd* pMainFrame = dynamic_cast<CWnd*>(IVisualManager::GetVisualManager()->GetMainWindow());
		pMainFrame->GetClientRect(rect);
		m_JournalButton.Create(CRect(195, 130, rect.right - 20, 130 + 80), pMainFrame, JOURNAL_ID);
	}
	return dynamic_cast<IWnd*>(&m_JournalButton);
}

IWnd* CJournalVisualComponent::GetComponentFrame(){
	return dynamic_cast<IWnd*>(&m_JournalWin);
}
void CJournalVisualComponent::CreateComponentFrame(){
	if(!IsWindow(m_JournalWin)){
		LPCTSTR strClassName = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, 
			LoadCursor(GetModuleHandle(NULL), IDC_ARROW), 0,
			LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME)));
		CPoint winCorner(0,0);
		m_JournalWin.Create(strClassName,
			ILanguageManager::GetLanguageManager()->GetString(JOURNAL_CAPTION_ID).c_str(),
			WS_VISIBLE | WS_OVERLAPPEDWINDOW,
			CRect(winCorner, CSize(1000, 700)));
	}
	m_JournalWin.SetFocus();
}
void CJournalVisualComponent::UpdateComponent(){
	if(IsWindow(m_JournalWin))
		m_JournalWin.Invalidate(true);
}
void CJournalVisualComponent::Free(){
	delete this;
}
